//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.caigua.mgp.mg.codegen.customize.xmlmapper.elements;

import com.caigua.mgp.mg.internal.CustomizeIntrospectedTableMyBatis3Impl;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;

public class CustomizeQueryByIdsElementGenerator extends CustomizeAbstractXmlElementGenerator {
    public CustomizeQueryByIdsElementGenerator() {
    }

    public void addElements(XmlElement parentElement) {
        XmlElement answer = new XmlElement("select");
        answer.addAttribute(new Attribute("id", ((CustomizeIntrospectedTableMyBatis3Impl)this.introspectedTable).getQueryByIds()));
        answer.addAttribute(new Attribute("resultMap", this.introspectedTable.getBaseResultMapId()));
        this.context.getCommentGenerator().addComment(answer);
        XmlElement foreachElement = new XmlElement("foreach");
        foreachElement.addAttribute(new Attribute("collection", "list"));
        foreachElement.addAttribute(new Attribute("item", "id"));
        foreachElement.addAttribute(new Attribute("separator", " union all "));
        StringBuilder sb = new StringBuilder();
        sb.append("select ");
        foreachElement.addElement(new TextElement(sb.toString()));
        foreachElement.addElement(this.getBaseColumnListElement());
        sb.setLength(0);
        sb.append("from ");
        sb.append(this.introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
        sb.append(" where id = #{id,jdbcType=BIGINT}");
        foreachElement.addElement(new TextElement(sb.toString()));
        answer.addElement(foreachElement);
        if (this.context.getPlugins().sqlMapSelectAllElementGenerated(answer, this.introspectedTable)) {
            parentElement.addElement(answer);
        }

    }
}
